/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JProductStorePanel.java
 *
 * Created on 2010-4-8, 8:50:29
 */

package com.openbravo.pos.panels.link;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import cn.ekuma.epos.datalogic.I_DataLogicSales;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.gui.MessageInf;
import com.openbravo.pos.base.AppLocal;
import com.openbravo.pos.panels.link.model.ProductStoreVTableModel;
import com.openbravo.bean.Product;
import com.openbravo.bean.viewbean.ProductStoreView;

/**
 *
 * @author Administrator
 */
@SuppressWarnings("serial")
public class JProductStorePanel extends AbstractProductLinkTablePanel<ProductStoreView>{

    private ButtonGroup buttonGroup1;
	private JRadioButton jAll;
	private JRadioButton jVirtual;
	private JRadioButton jPhysical;

	/** Creates new form JProductStorePanel */
    public JProductStorePanel(I_DataLogicSales dlSales) {
       super(dlSales,new ProductStoreVTableModel());
    }

    @Override
	public void baseBeanChanged(Product o) {
    	try {
        	if(jAll.isSelected())
               tableModel.resert(dlSales.listByFilter(ProductStoreView.class,createValue()));
        	else if(jVirtual.isSelected())
        		tableModel.resert(dlSales.listByIdAndVirtual(baseBeanID, true));
        	else
        		tableModel.resert(dlSales.listByIdAndVirtual(baseBeanID, false));
        } catch (BasicException ex) {
            tableModel.resert(null);
            new MessageInf(ex).show(this);
        }
	}

	@Override
	public JPanel getToolBar() {
		JPanel toolbar=new JPanel();
		buttonGroup1 = new javax.swing.ButtonGroup();
        jAll = new javax.swing.JRadioButton();
        jVirtual = new javax.swing.JRadioButton();
        jPhysical = new javax.swing.JRadioButton();

        toolbar.setLayout(new javax.swing.BoxLayout(toolbar, javax.swing.BoxLayout.LINE_AXIS));

        buttonGroup1.add(jAll);
        jAll.setText(AppLocal.getIntString("label.all")); // NOI18N
        jAll.setFocusPainted(false);
        jAll.setFocusable(false);
        toolbar.add(jAll);

        buttonGroup1.add(jVirtual);
        jVirtual.setText(AppLocal.getIntString("label.isVirtual")); // NOI18N
        jVirtual.setFocusPainted(false);
        jVirtual.setFocusable(false);
        toolbar.add(jVirtual);

        buttonGroup1.add(jPhysical);
        jPhysical.setSelected(true);
        jPhysical.setText(AppLocal.getIntString("label.isPhysical")); // NOI18N
        jPhysical.setFocusPainted(false);
        jPhysical.setFocusable(false);
        toolbar.add(jPhysical);
		return toolbar;
	}
    
    
}
